package com.castte.game.snake;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

public class GameoverActivaty extends Activity {

	static final int GAMEOVER_DIALOG = 1;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		showDialog(GAMEOVER_DIALOG);
	}
	
	protected Dialog onCreateDialog(int id){
		switch (id) {
		case GAMEOVER_DIALOG:
			return buildGameoverDialog(this);

		default:
			return null;
		}
	}
	
	Dialog buildGameoverDialog(Context context){
		int action = 0; //1 retry 2 exit
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder.setTitle(R.string.gameover);
		builder.setPositiveButton(R.string.playagain, new DialogInterface.OnClickListener(){
			@Override
			public void onClick(DialogInterface dialog, int which) {
				tryAgain();
			}});
		builder.setNegativeButton(R.string.exit,new DialogInterface.OnClickListener(){
			@Override
			public void onClick(DialogInterface dialog, int which) {
				exitGame();
			}});
		
		
		return builder.create();
	}
	
	void tryAgain(){
		Intent intent = new Intent(this,SnakeMain.class);
		startActivity(intent);
		this.finish();
	}
	
	void exitGame(){
		this.finish();
	}
	
}
